<?php

class Empeval_Exception_App extends Empeval_Exception_Core {

	const TYPE_INFO = 'information';
	const TYPE_ERROR = 'error';
	
	public function __construct($code, $args=null) {
		$config = Empeval_Core::getInstance()->getConfigs()->log;
		$filename = Zend_Controller_Front::getInstance()->getModuleDirectory() . $config->app->errorsFilename;
		if (!file_exists($filename))
			throw new Exception("File: " . $filename . " doesn't exist");
		$errorsXml = new Zend_Config_Xml($filename);
		$codeXml = 'e' . $code;
		$errorDef = $errorsXml->$codeXml;
		$this->type = $errorDef->type;
		$this->code = $code;
		$this->doLog = (bool)$config->app->power;
		$this->message = vsprintf($errorDef->system, $args);
		$this->userMessage = $errorDef->user;
		parent::__construct();
	}

}